SPB Git

Repository Public

route.ts 924 B 15 lines typescript

1import { OpError, publish } from "@/lib/studio-ops";2import { isUuid, out, studio } from "@/lib/studio-api";34/** POST /api/studio/films/:id/publish — :id is the project id. Requires an approval of the current cut. { scheduleFor?: ISO date, featured?: boolean } */5export async function POST(req: Request, ctx: { params: Promise<{ id: string }> }) {6  const { id } = await ctx.params;7  return studio(req, "editor", async (user, body) => {8    if (!isUuid(id)) throw new OpError("Project not found", 404);9    const when = typeof body.scheduleFor === "string" ? new Date(body.scheduleFor) : null;10    if (when && Number.isNaN(when.getTime())) throw new OpError("scheduleFor is not a valid date");11    const filmId = await publish(user, id, { scheduleFor: when, featured: body.featured === true });12    return out({ projectId: id, filmId, status: when && when.getTime() > Date.now() ? "scheduled" : "published" });13  });14}15
Files main
Menu

Theme